#ifndef TEXTURE_H_
#define TEXTURE_H_

#include <gl.h>
#include "File.h"

namespace Lame3d
{
	class Texture
	{
		public:
			Texture(const File &f);
			~Texture();
			
			class Handle
			{
				public:
					~Handle();
					
					void Bind2d();
					void Coord(float u, float v);
					GLuint GlTexture();
					
					Handle& operator=(const Handle &h);
				
				protected:
					Handle(Texture &t);
					Texture *texture;
									
				friend class Texture;					
			};
			
			Handle GetHandle();
		
		protected:
			int refCount;
			GLuint glTexture;
			File file;
			
			void load();
			void unload();
			
		friend class Handle;
	};
}

#endif /*TEXTURE_H_*/
